package com.yzt.zhuju.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yzt.zhuju.R;

/**
 * author : bob
 * date   : 2022/11/29
 * desc   :
 */
public class ProgressDialog extends Dialog {

    private View layoutView;

    private TextView mShowTv;

    public ProgressDialog(Context context) {
        super(context, R.style.MProgressDialog);
        initViews();
    }

    private void initViews() {
        layoutView = getLayoutInflater().inflate(R.layout.view_layout_progress, null);
        mShowTv = layoutView.findViewById(R.id.show_tv);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(layoutView, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
        //设置点击屏幕不消失
        this.setCanceledOnTouchOutside(false);
    }

    public void setShowContent(String content) {
        if (TextUtils.isEmpty(content)) {
            mShowTv.setVisibility(View.GONE);
        } else {
            mShowTv.setVisibility(View.VISIBLE);
            mShowTv.setText(content);
        }
    }
}

